package com.smartboot.plus.wapper;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.smartboot.plus.ignite.cache.MqttAclCache;
import com.smartboot.plus.support.BaseMqttEntityWrapper;
import com.smartboot.plus.vo.MqttAclCacheVO;

public class MqttAclWrapper extends BaseMqttEntityWrapper<MqttAclCache, MqttAclCacheVO> {

    public static MqttAclWrapper build() {
        return new MqttAclWrapper();
    }

    @Override
    public MqttAclCacheVO entityVO(MqttAclCache entity) {
        try{
            String json = JSON.toJSONString(entity);
            MqttAclCacheVO mqttAclCacheVO = JSONObject.parseObject(json, MqttAclCacheVO.class);
            mqttAclCacheVO.setTopicEft(mqttAclCacheVO.getTopicEft());

            return mqttAclCacheVO;

        }catch (Exception e){
            return null;
        }
    }
}
